package com.shopping.mall.core.module.user.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.sql.Timestamp;

/**
 * User实体类
 *
 * @author zzy
 * @date 2021-07-27
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("user")
public class User {

    public interface insert {
    }

    public interface update {
    }

    @ApiModelProperty(value = "用户ID")
    @TableId(type = IdType.UUID)
    private String id;

    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "姓")
    private String familyName;

    @ApiModelProperty(value = "密码(passwordEncoder加密)")
    private String password;

    @ApiModelProperty(value = "邮箱")
    private String mail;

    @ApiModelProperty(value = "用户角色(1普通用户,2企业用户)")
    private Integer roleId;

    @ApiModelProperty(value = "手机号")
    private String phone;

    @ApiModelProperty(value = "年龄")
    private Integer age;

    @ApiModelProperty(value = "性别")
    private Integer gender;

    @ApiModelProperty(value = "地址")
    private String place;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp createAt;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp updateAt;

    @TableField(exist = false)
    private Role role;

    @TableField(exist = false)
    private String languageId;

    @TableLogic
    private Integer isDeleted;

    public User(UserExcelVo userExcelVo){
        this.username=userExcelVo.getName2();
        this.familyName=userExcelVo.getName1();
        this.mail=userExcelVo.getMail();
        this.phone=userExcelVo.getPhone();
        //abc123456
        this.password="$2a$10$rS5OuLEUZ.2vhOXJTsDj2uX9QFcepFQ6VWP0N3pTYlR7HCcKJLBGG";
        this.roleId=1;
    }

}
